For Each Wizard
What does it do?
The For Each wizard creates dynamic reference and index fields to loop through items from an item collection.
How is it used?
The For Each wizard can be used in any scenario where an item collection must be converted into a list of items items where something must be to done to each item in the list. This wizard is typically used in conjunction with the Create Reference wizard. The source list can be one of the following:
- An Item Reference created in the workflow
- An item collection from the Context Browser
- A semicolon-delimited text
Prerequisites
If an Item Reference or item collection is used as the source list of items, this must exist before dragging the For Each wizard onto the canvas.
Configure the list to loop through
Provide the Source, Reference and Index for use in the creation of the list.
Field |
Description |
Sample Value |
Source |
The source list to loop through. It can be one of the following:
- An Item Reference created in the workflow. The Item Reference must contain a list or collection of items.
- An item collection from the Context Browser
- A semicolon-delimited text
|
Select a value from the drop down list, type semicolon-delimited text or drag and drop a field from the Context Browser. Click the toggle button to change the type of input |
Reference |
The name of the Reference to be created. The field is auto-populated using the SmartObject selected. Specify another name if required |
Type text in the field |
Index |
The Index name used to create a Data Field Field which in turn serves as a unique identifier for each item in the list in order for the wizard to keep track of the items. The workflow automatically creates two outcomes for the For Each wizard (see next section for example):
- Next Item - Index field used to determine if there is a next item
- No More Items - Index field used to determine if there are no remaining items
|
Type text in the field. No user actions are required to create the outcomes |
Automatically generated outcomes
The For Each wizard automatically creates two outcomes as part of the workflow. These outcomes are used to determine whether the loop should continue or not.
Outcome rules are created for each outcome. As long as the outcome rule for the Next Item resolves to true, the loop will continue.
How to use the For Each wizard
It is important to take note of the steps to follow when using the For Each wizard as failing to do so might result in unexpected behavior. The next steps can be followed as a guide to complete the set up of the For Each wizard:
- Create a source to loop through
- Drag the For Each wizard onto the canvas
- Configure the wizard
- Add more workflow steps to the Next Item outcome if required. One example is to send an email using the email address of the Item Reference created. Multiple workflow steps can be added to this outcome if required
- Manually create a loop back from the last outcome in the Next Item path to the For Each wizard step by linking the outcome to the For Each as shown below. As a result, for every item in the collection, it will send an email to all email addresses within the collection until no items remain in the list. The workflow then continues to the No More Items outcome.
- Continue configuring the workflow as required
Considerations
- The Create Reference wizard can be used with the For Each wizard as outputs from the Create Reference wizard are displayed as a flat list which is converted to a list of items within the For Each wizard.
- A loop back should be created from the last outcome in the Next Item outcome path to the For Each wizard to ensure that the loop is closed. See the How to use the For Each wizard section.
- If the loop back to the For Each wizard is not created, the loop function itself will not occur.